package homework.no_3;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Scanner;

public class ClientTest {
    public static void main(String[] args) {
        Socket socket = null;
        DataInputStream dis = null;
        ObjectOutputStream oos = null;

        try {
            socket = new Socket("192.168.1.178",8800);
            dis = new DataInputStream(socket.getInputStream());
            oos = new ObjectOutputStream(socket.getOutputStream());

            Scanner sc = new Scanner(System.in);
            System.out.print("请输入用户名：");
            String name = sc.nextLine();
            System.out.print("请输入密码：");
            String pwd = sc.nextLine();

            User user = new User(name,pwd);
            oos.writeObject(user);
            boolean flag = dis.readBoolean();
            if (flag){
                System.out.println("登录成功！");
            }else {
                System.out.println("登录失败！");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
